import { onMounted, onUnmounted, ref } from "vue";

export const useTimer = (fn: () => void) => {
  const timer = ref(0);

  onMounted(() => {
    timer.value = setInterval(() => {
      fn();
    }, 1000);
  })

  onUnmounted(() => {
    clearInterval(timer.value);
  })

  return {
    timer,
  }
}